package com.authine.cloudpivot.app.openapi.executor;

import com.authine.cloudpivot.app.openapi.constants.RedisKeyConstant;
import com.authine.cloudpivot.app.openapi.domain.openapi.UserInfoValue;
import com.authine.cloudpivot.app.openapi.dto.OpenUserInfoRes;
import com.authine.hermes.lib.cloudpivot.cache.core.command.RedisHashMap;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * @author lifuchun
 */
@Service
public class GetUserInfoQry {


    public OpenUserInfoRes execute(String openToken) {

        RedisHashMap redisObject3 = new RedisHashMap(String.format(RedisKeyConstant.KEY_OPENAPI_TOKEN, openToken));

        UserInfoValue userInfoValue = (UserInfoValue) redisObject3.get(RedisKeyConstant.MAP_KEY_USER_INFO_VALUE);

        OpenUserInfoRes openUserInfoRes = new OpenUserInfoRes();
        BeanUtils.copyProperties(userInfoValue, openUserInfoRes);

        return openUserInfoRes;
    }
}
